package com.coderman.infosys.plat.auth.common.exception;

/**
 * Description:异常基类
 * date: 2022/1/5
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
public class ExceptionBase  extends RuntimeException {
    public ExceptionBase(String msg) {
        super(msg);
    }


    /**
     * 异常对应的rpc码
     */
    private int rpcCode = 500;

    /**
     * 错误码
     */
    private String errCode = Integer.toString(rpcCode);

    /**
     * 是否异常型错误，true-表示系统故障或数据出现异常 false-表示正常逻辑的失败分支
     */
    private boolean fault;


    /**
     * 是否是通过Exceptions.fail或fault这种方式来的
     */
    private boolean fromExceptionsMethod;


    public ExceptionBase(){

    }

    public ExceptionBase(String errCode, String errorMsg) {
        super(errorMsg);
        this.errCode = errCode;
    }

    public ExceptionBase(int httpCode, String errCode, String errorMsg, Throwable e) {
        super(errorMsg, e);
        this.rpcCode = httpCode;
        this.errCode = errCode;

    }

    public ExceptionBase(int httpCode, String errCode, String errorMsg) {
        super(errorMsg);
        this.rpcCode = httpCode;
        this.errCode = errCode;
    }

    public int getRpcCode() {
        return rpcCode;
    }

    public void setRpcCode(int rpcCode) {
        this.rpcCode = rpcCode;
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public boolean isFault() {
        return fault;
    }

    public void setFault(boolean isFault) {
        this.fault = isFault;
    }

    public boolean isFromExceptionsMethod() {
        return fromExceptionsMethod;
    }

    public void setFromExceptionsMethod(boolean fromExceptionsMethod) {
        this.fromExceptionsMethod = fromExceptionsMethod;
    }

}
